/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rhdtp.demopf.security;

import com.rhdtp.demopf.model.dto.Usuario;
import javax.faces.context.FacesContext;

/**
 *
 * @author rhdtp
 */
public class UserSession {

    public UserSession() {
    }

    private Usuario user;

    public int getRol() {
        FacesContext context = FacesContext.getCurrentInstance();
        user = (Usuario) context.getExternalContext().getSessionMap().get("user");
        return user.getRol().getId();
    }

    public String getRolName() {
        FacesContext context = FacesContext.getCurrentInstance();
        user = (Usuario) context.getExternalContext().getSessionMap().get("user");
        return user.getRol().getNombre();
    }

    public String getUserName() {
        FacesContext context = FacesContext.getCurrentInstance();
        user = (Usuario) context.getExternalContext().getSessionMap().get("user");
        String userName = user.getNombre();
        return userName;
    }
    
    public String getNick() {
        FacesContext context = FacesContext.getCurrentInstance();
        user = (Usuario) context.getExternalContext().getSessionMap().get("user");
        String nick = user.getNick();
        return nick;
    }

    /**
     * @return the user
     */
    public Usuario getUser() {
        return user;
    }

    /**
     * @param user the user to set
     */
    public void setUser(Usuario user) {
        this.user = user;
    }
}
